package com.chat.api.web.restctrl;

import com.chat.api.utils.ResultUtil;
import com.chat.api.web.service.MomentDataService;
import com.chat.api.web.vo.MessageEntity;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@RequestMapping("/api/momentDate")
public class MomentDataCtrl {

    @Autowired
    private MomentDataService momentDataService;

    @RequestMapping("getOnlineReader")
    @ApiOperation("获取在线人数数量、定位信息")
    public MessageEntity getOnlineReader(HttpServletRequest request) {
        return momentDataService.getOnlineReader(request);
    }

    @RequestMapping("getReadInfo")
    @ApiOperation("获取博客阅读统计信息")
    public MessageEntity getReadInfo(HttpServletRequest request) {
        return momentDataService.getReadInfo(request);
    }

    @RequestMapping("downPdfFile")
    @ApiOperation("下载博客统计数据")
    public void downPdfFile(HttpServletRequest request, HttpServletResponse response) {
        try {
            momentDataService.downPdfFile(request,response);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
